<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">获取余额</button>
    <script src="./js/jquery.min-1.10.2.js"></script>
    <script>
        $("#btn").click(function(){
            /**
             * 解决地狱回调
             * 1,登录
             * r = login()
             * yue = banlance();
             */
            //  f1();
            getBanlance();
        })
        async function getBanlance(){
            var nick = await new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    console.log("登录成功！");
                    resolve("孙悟空");
                },1000)
            });
            var yue = await new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    console.log("获取信息成功！");
                    resolve(100);
                },1000)
            });
            console.log(nick+"的余额是："+yue);
        }

        async function f1(){
            await new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    console.log("登录成功！");
                    resolve();
                },1000)
            });
            await new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    console.log("获取信息成功！");
                    resolve();
                },1000)
            });
            console.log("程序结束！");
        }
    </script>
</body>
</html>